<template>
  <div>
    <h3>动画测试</h3>
    <button @click="toggle">点击</button>
    <transition name="fade">
      <p v-if="isShow">动画</p>
    </transition>
  </div>
</template>

<script>
import { ref } from 'vue'
export default {
  setup () {
    const isShow = ref(false)
    const toggle = () => {
      isShow.value = !isShow.value
    }
    return { isShow, toggle }
  }
}
</script>

<style>
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
.fade-enter-active,
.fade-leave-active {
  transition: all 2s;
}
.fade-enter-to,
.fade-leave-from {
  opacity: 1;
}
</style>
